﻿using System;
using System.Collections.Generic;
using System.Web;

namespace FDeal
{
    public class ThanhToanBUS
    {
        private ThanhToanDAO _dDAO;

        public ThanhToanBUS()
        {
            _dDAO = new ThanhToanDAO();
        }

        public void Insert(ThanhToanDTO obj)
        {
            _dDAO.insert(obj);
        }

        public void Insert(string idhinhthuc, string tenhinhthuc, float phithanhtoan)
        {
            ThanhToanDTO obj = new ThanhToanDTO();

            obj.Idhinhthuc = idhinhthuc;
            obj.Phithanhtoan = phithanhtoan;
            obj.Tenhinhthuc = tenhinhthuc;

            this.Insert(obj);
        }

        public void Delete(string idDeal)
        {
            _dDAO.delete(idDeal);
        }

        public void Update(ThanhToanDTO obj)
        {
            _dDAO.update(obj);
        }

        public ThanhToanDTO[] GetDsHinhThucThanhToan()
        {
            return _dDAO.getDsThanhToan();
        }

        public ThanhToanDTO GetHinhThucThanhToan(string idThanhToan)
        {
            ThanhToanDTO[] ds = this.GetDsHinhThucThanhToan();

            for (int i = 0; i < ds.Length; i++)
            {
                if (ds[i].Idhinhthuc.Equals(idThanhToan))
                    return ds[i];
            }
            return null;
        }
    }
}